@extends('admin.common.base-master')

@section('html-head')
    <style type="text/css">
        .divcss5_list_title{background:#eeeeee; border:1px solid #cccccc; padding:1em;}
        .divcss5_list_content{padding:1em;}
        #tinybox{position:absolute; display:none; padding:10px; background:url('{{url('images/preload.gif')}}') no-repeat 50% 50%;  z-index:2000;}
        #tinymask{position:absolute; display:none; top:0; left:0; height:100%; width:100%; background:#000000; z-index:1500;}
        #tinycontent{background:#ffffff; font-size:1.1em;}

        #n{margin:10px auto; width:920px; border:1px solid #CCC;font-size:12px; line-height:30px;}
        #n a{ padding:0 4px; color:#333}
        .sx{padding: 10px}
        .sx-btn{width: 64px;height: 30px;background-color: #4dbcd3;color: #fff;border: #4dbcd3;border-radius: 7%;}
    </style>
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">打卡任务</a>
        </div>

        <div class="filter-box clearfix">
            <div class="fr" style="margin-top: 10px;">
                <a class="addBtn" href="{{route("Admin.Home.dakaContentSet")}}">新增</a>
            </div>
        </div>
        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>发布者</th>
                    <th>默认图标</th>
                    <th>文章标题</th>
                    <th>描述</th>
                    <th>文章内容</th>
                    <th>打卡数量</th>
                    <th>用户参与人数</th>
                    <th>默认显示</th>
                    <th>二维码</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($dakaList) > 0)
                    @foreach($dakaList as $daka_content)
                        <tr id="q_{{$daka_content->id}}">
                            <td>{{$daka_content->id}}</td>
                            <td>@if($daka_content->user_id == 0)管理员@else 未知 @endif</td>
                            <td style="width: 90px">
                                  <span class="photo" style="border-radius: 100%;display:initial">
                                    @if($daka_content->img_id !== 0)
                                          <img style="width: 100%" src="{{route('Api.File.showImageById',['id'=>$daka_content->img_id])}}" alt="" />
                                    @endif
                                 </span>
                            </td>
                            <td>{{$daka_content->title}}</td>
                            <td>{{$daka_content->desc}}</td>
                            <td>查看</td>
                            <td>{{$daka_content->daka_count}}</td>
                            <td>{{$daka_content->user_count}}</td>
                            <td>@if($daka_content->is_active == 1)<span class="color2">是</span> @else <span class="color5">否</span> @endif</td>
                            <td style="width: 80px">
                                 <span class="photo" style="border-radius: 100%;display:initial">
                                    @if($daka_content->img_id !== 0)
                                         <img style="width: 100%" src="{{route('Api.File.showImageById',['id'=>$daka_content->qrcode_img_id])}}" alt="" />
                                     @endif
                                 </span>
                            </td>
                            <td>{{$daka_content->created_at}}</td>
                            <td><a class="color2" href="@if($daka_content){{route('Admin.Home.dakaContentSet')}}?d_id={{$daka_content->id}} @endif">编辑</a> <span>|</span> <a href="javascript:void(0);" class="del" data-id="{{$daka_content->id}}">删除 </a></td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                <tfoot class="order-gl">

                </tfoot>
            </table>
        </div>
    </div>

    <script>
        $(function () {
            $(document).on("click", ".del", function () {
                var id = $(this).attr("data-id");

                noty({
                    text: '可能影响打卡任务，你确定要删除吗?',
                    buttons: [
                        {
                            addClass: 'btn btn-primary', text: '确定', onClick: function ($noty) {
                                $noty.close();
                                $.ajax({
                                    url: '{{route('Api.Admin.daka.delDaka')}}',
                                    type: 'post',
                                    dataType: 'json',
                                    data: {d_id: id},
                                    success: function (obj) {
                                        if (obj.level == "success") {
                                            window.location.reload();
                                        } else {
                                            noty({type: obj.level, text: obj.message, timeout: 600});
                                        }
                                    },
                                    error: function (obj) {
                                        console.log(obj);
                                    }

                                });
                            }
                        },
                        {
                            addClass: 'btn btn-danger', text: '取消', onClick: function ($noty) {
                                $noty.close();
                            }
                        }
                    ]
                });
            });
        })
    </script>
@endsection